This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Data was downloaded (by hand, API was not found) from VMI laskentapalvelu (Valtakunnallinen mets??inventaari), and the data was from years 2009-2013. Parameters for the data download: forest area, tree volume, and tree number were searchded for 20-year age groups, areas categorised by the main tree species, seach including both forests and kitumaa (poorly growing areas), and using district levels.

dsets <- list_statfi_files()
Downloading http://pxweb2.stat.fi/database/StatFin/StatFin_rap.csv
InternetOpenUrl failed: 'A connection with the server could not be established'Error in file(file, "rt") : cannot open the connection
No files available at http://pxweb2.stat.fi/database/StatFin/StatFin_rap.csv
tmp <- dat[dat$Variable=="Tilavuus",]
tmp <- aggregate(tmp["Tulos"], tmp[c("Alue","Ikaluokka")], sum)
pl <- tmp %>%
#  group_by(Alue) %>%
  plot_ly(x=~Ikaluokka, y=~Tulos, color=~Alue, type="bar") %>%
  layout(
#    barmode="group",
    yaxis=list(title="Puuston tilavuus (1000 m3)")
  )
pl
minimal value for n is 3, returning requested palette with 3 different levels
minimal value for n is 3, returning requested palette with 3 different levels
minimal value for n is 3, returning requested palette with 3 different levels
minimal value for n is 3, returning requested palette with 3 different levels

pushIndicatorGraph(pl, 124)
minimal value for n is 3, returning requested palette with 3 different levels
minimal value for n is 3, returning requested palette with 3 different levels
[1] "API call failed with HTTP 400:\nlist(detail = \"Invalid Plotly object received:\\n\\nInvalid property specified for object of type plotly.graph_objs.Bar: 'frame'\\n\\n    Valid properties:\\n        alignmentgroup\\n            Set several traces linked to the same position axis or\\n            matching axes to the same alignmentgroup. This controls\\n            whether bars compute their positional range dependently\\n            or independently.\\n        base\\n            Sets where the bar base is drawn (in position axis\\n            units). In \\\"stack\\\" or \\\"relative\\\" barmode, traces that\\n            set \\\"base\\\" will be excluded and drawn in \\\"overlay\\\" mode\\n            instead.\\n        basesrc\\n            Sets the source reference on plot.ly for  base .\\n        cliponaxis\\n            Determines whether the text nodes are clipped about the\\n            subplot axes. To show the text nodes above axis lines\\n            and tick labels, make sure to set `xaxis.layer` and\\n            `yaxis.layer` to *below traces*.\\n        constraintext\\n            Constrain the size of text inside or outside a bar to\\n            be no larger than the bar itself.\\n        customdata\\n            Assigns extra data each datum. This may be useful when\\n            listening to hover, click and selection events. Note\\n            that, \\\"scatter\\\" traces also appends customdata items in\\n            the markers DOM elements\\n        customdatasrc\\n            Sets the source reference on plot.ly for  customdata .\\n        dx\\n            Sets the x coordinate step. See `x0` for more info.\\n        dy\\n            Sets the y coordinate step. See `y0` for more info.\\n        error_x\\n            plotly.graph_objs.bar.ErrorX instance or dict with\\n            compatible properties\\n        error_y\\n            plotly.graph_objs.bar.ErrorY instance or dict with\\n            compatible properties\\n        hoverinfo\\n            Determines which trace information appear on hover. If\\n            `none` or `skip` are set, no information is displayed\\n            upon hovering. But, if `none` is set, click and hover\\n            events are still fired.\\n        hoverinfosrc\\n            Sets the source reference on plot.ly for  hoverinfo .\\n        hoverlabel\\n            plotly.graph_objs.bar.Hoverlabel instance or dict with\\n            compatible properties\\n        hovertemplate\\n            Template string used for rendering the information that\\n            appear on hover box. Note that this will override\\n            `hoverinfo`. Variables are inserted using %{variable},\\n            for example \\\"y: %{y}\\\". Numbers are formatted using\\n            d3-format's syntax %{variable:d3-format}, for example\\n            \\\"Price: %{y:$.2f}\\\". See https://github.com/d3/d3-format\\n            /blob/master/README.md#locale_format for details on the\\n            formatting syntax. The variables available in\\n            `hovertemplate` are the ones emitted as event data\\n            described at this link\\n            https://plot.ly/javascript/plotlyjs-events/#event-data.\\n            Additionally, every attributes that can be specified\\n            per-point (the ones that are `arrayOk: true`) are\\n            available.  Anything contained in tag `<extra>` is\\n            displayed in the secondary box, for example\\n            \\\"<extra>{fullData.name}</extra>\\\". To hide the secondary\\n            box completely, use an empty tag `<extra></extra>`.\\n        hovertemplatesrc\\n            Sets the source reference on plot.ly for  hovertemplate\\n            .\\n        hovertext\\n            Sets hover text elements associated with each (x,y)\\n            pair. If a single string, the same string appears over\\n            all the data points. If an array of string, the items\\n            are mapped in order to the this trace's (x,y)\\n            coordinates. To be seen, trace `hoverinfo` must contain\\n            a \\\"text\\\" flag.\\n        hovertextsrc\\n            Sets the source reference on plot.ly for  hovertext .\\n        ids\\n            Assigns id labels to each datum. These ids for object\\n            constancy of data points during animation. Should be an\\n            array of strings, not numbers or any other type.\\n        idssrc\\n            Sets the source reference on plot.ly for  ids .\\n        insidetextfont\\n            Sets the font used for `text` lying inside the bar.\\n        legendgroup\\n            Sets the legend group for this trace. Traces part of\\n            the same legend group hide/show at the same time when\\n            toggling legend items.\\n        marker\\n            plotly.graph_objs.bar.Marker instance or dict with\\n            compatible properties\\n        name\\n            Sets the trace name. The trace name appear as the\\n            legend item and on hover.\\n        offset\\n            Shifts the position where the bar is drawn (in position\\n            axis units). In \\\"group\\\" barmode, traces that set\\n            \\\"offset\\\" will be excluded and drawn in \\\"overlay\\\" mode\\n            instead.\\n        offsetgroup\\n            Set several traces linked to the same position axis or\\n            matching axes to the same offsetgroup where bars of the\\n            same position coordinate will line up.\\n        offsetsrc\\n            Sets the source reference on plot.ly for  offset .\\n        opacity\\n            Sets the opacity of the trace.\\n        orientation\\n            Sets the orientation of the bars. With \\\"v\\\" (\\\"h\\\"), the\\n            value of the each bar spans along the vertical\\n            (horizontal).\\n        outsidetextfont\\n            Sets the font used for `text` lying outside the bar.\\n        r\\n            r coordinates in scatter traces are deprecated!Please\\n            switch to the \\\"scatterpolar\\\" trace type.Sets the radial\\n            coordinatesfor legacy polar chart only.\\n        rsrc\\n            Sets the source reference on plot.ly for  r .\\n        selected\\n            plotly.graph_objs.bar.Selected instance or dict with\\n            compatible properties\\n        selectedpoints\\n            Array containing integer indices of selected points.\\n            Has an effect only for traces that support selections.\\n            Note that an empty array means an empty selection where\\n            the `unselected` are turned on for all points, whereas,\\n            any other non-array values means no selection all where\\n            the `selected` and `unselected` styles have no effect.\\n        showlegend\\n            Determines whether or not an item corresponding to this\\n            trace is shown in the legend.\\n        stream\\n            plotly.graph_objs.bar.Stream instance or dict with\\n            compatible properties\\n        t\\n            t coordinates in scatter traces are deprecated!Please\\n            switch to the \\\"scatterpolar\\\" trace type.Sets the\\n            angular coordinatesfor legacy polar chart only.\\n        text\\n            Sets text elements associated with each (x,y) pair. If\\n            a single string, the same string appears over all the\\n            data points. If an array of string, the items are\\n            mapped in order to the this trace's (x,y) coordinates.\\n            If trace `hoverinfo` contains a \\\"text\\\" flag and\\n            \\\"hovertext\\\" is not set, these elements will be seen in\\n            the hover labels.\\n        textfont\\n            Sets the font used for `text`.\\n        textposition\\n            Specifies the location of the `text`. \\\"inside\\\"\\n            positions `text` inside, next to the bar end (rotated\\n            and scaled if needed). \\\"outside\\\" positions `text`\\n            outside, next to the bar end (scaled if needed), unless\\n            there is another bar stacked on this one, then the text\\n            gets pushed inside. \\\"auto\\\" tries to position `text`\\n            inside the bar, but if the bar is too small and no bar\\n            is stacked on this one the text is moved outside.\\n        textpositionsrc\\n            Sets the source reference on plot.ly for  textposition\\n            .\\n        textsrc\\n            Sets the source reference on plot.ly for  text .\\n        tsrc\\n            Sets the source reference on plot.ly for  t .\\n        uid\\n            Assign an id to this trace, Use this to provide object\\n            constancy between traces during animations and\\n            transitions.\\n        uirevision\\n            Controls persistence of some user-driven changes to the\\n            trace: `constraintrange` in `parcoords` traces, as well\\n            as some `editable: true` modifications such as `name`\\n            and `colorbar.title`. Defaults to `layout.uirevision`.\\n            Note that other user-driven trace attribute changes are\\n            controlled by `layout` attributes: `trace.visible` is\\n            controlled by `layout.legend.uirevision`,\\n            `selectedpoints` is controlled by\\n            `layout.selectionrevision`, and `colorbar.(x|y)`\\n            (accessible with `config: {editable: true}`) is\\n            controlled by `layout.editrevision`. Trace changes are\\n            tracked by `uid`, which only falls back on trace index\\n            if no `uid` is provided. So if your app can add/remove\\n            traces before the end of the `data` array, such that\\n            the same trace has a different index, you can still\\n            preserve user-driven changes if you give each trace a\\n            `uid` that stays with it as it moves.\\n        unselected\\n            plotly.graph_objs.bar.Unselected instance or dict with\\n            compatible properties\\n        visible\\n            Determines whether or not this trace is visible. If\\n            \\\"legendonly\\\", the trace is not drawn, but can appear as\\n            a legend item (provided that the legend itself is\\n            visible).\\n        width\\n            Sets the bar width (in position axis units).\\n        widthsrc\\n            Sets the source reference on plot.ly for  width .\\n        x\\n            Sets the x coordinates.\\n        x0\\n            Alternate to `x`. Builds a linear space of x\\n            coordinates. Use with `dx` where `x0` is the starting\\n            coordinate and `dx` the step.\\n        xaxis\\n            Sets a reference between this trace's x coordinates and\\n            a 2D cartesian x axis. If \\\"x\\\" (the default value), the\\n            x coordinates refer to `layout.xaxis`. If \\\"x2\\\", the x\\n            coordinates refer to `layout.xaxis2`, and so on.\\n        xcalendar\\n            Sets the calendar system to use with `x` date data.\\n        xsrc\\n            Sets the source reference on plot.ly for  x .\\n        y\\n            Sets the y coordinates.\\n        y0\\n            Alternate to `y`. Builds a linear space of y\\n            coordinates. Use with `dy` where `y0` is the starting\\n            coordinate and `dy` the step.\\n        yaxis\\n            Sets a reference between this trace's y coordinates and\\n            a 2D cartesian y axis. If \\\"y\\\" (the default value), the\\n            y coordinates refer to `layout.yaxis`. If \\\"y2\\\", the y\\n            coordinates refer to `layout.yaxis2`, and so on.\\n        ycalendar\\n            Sets the calendar system to use with `y` date data.\\n        ysrc\\n            Sets the source reference on plot.ly for  y .\\n        \", \n    source = list(pointer = \"/data/attributes/data\"), status = \"400\")"
Error in pushIndicatorGraph(pl, 124) : Bad Request (HTTP 400).

Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

LS0tDQp0aXRsZTogIkZldGNoIGZvcmVzdCBkYXRhIGZyb20gU3RhdGlzdGljcyBGaW5sYW5kIg0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCg0KVGhpcyBpcyBhbiBbUiB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